let modal = {
  /**
   * Modal.confirmInput(_this,{title: '标题',content: '提示语'}, function (val) {}, function () {});
   * */
  confirmModal: function (context, params, handlerFunc, backFunc) {
    var content = params.content ? params.content : '';
    var title = params.title ? params.title : '温馨提示';
    var okText = params.okText ? params.okText : '确定';
    var cancelText = params.cancelText ? params.cancelText : '取消';
    var value = '';
    context.$Modal.confirm({
      title: title,
      content: content,
      closable: true,
      okText: okText,
      cancelText: cancelText,
      onOk: () => {
        if (handlerFunc) {
          handlerFunc();
        }
      },
      onCancel: () => {
        if (backFunc) {
          backFunc();
        }
      }
    });
  },
  /**
   * Modal.confirmInput(_this,{content: '提示语'}, function (val) {}, function () {});
   * */
  confirmInput: function (context, params, handlerFunc, backFunc) {
    var content = params.content ? params.content : '';
    var title = params.title ? params.title : '温馨提示';
    var okText = params.okText ? params.okText : '确定';
    var cancelText = params.cancelText ? params.cancelText : '取消';
    var value = '';
    context.$Modal.info({
      title: content,
      content: '',
      closable: true,
      okText: okText,
      cancelText: cancelText,
      render: (h) => {
        return h('Input', {
          props: {
            value: '',
            autofocus: true,
            placeholder: content
          },
          on: {
            input: (val) => {
              value = val;
            }
          }
        })
      },
      onOk: () => {
        if (handlerFunc) {
          handlerFunc(value);
        }
      },
      onCancel: () => {
        if (backFunc) {
          backFunc();
        }
      }
    });
  },
  /**
   * Modal.confirm(_this,{content: '提示语'}, function () {}, function () {});
   * */
  confirm: function (context, params, handlerFunc, backFunc) {
    var content = params.content ? params.content : '';
    var title = params.title ? params.title : '温馨提示';
    var okText = params.okText ? params.okText : '确定';
    var cancelText = params.cancelText ? params.cancelText : '取消';
    context.$Modal.confirm({
      title: content,
      content: '',
      closable: true,
      okText: okText,
      cancelText: cancelText,
      onOk: () => {
        if (handlerFunc) {
          handlerFunc();
        }
      },
      onCancel: () => {
        if (backFunc) {
          backFunc();
        }
      }
    });
  },
  /**
   * 消息
   * Modal.info(_this,{content: '提示语'}, function () {}, function () {});
   * */
  info: function (context, params, handlerFunc, backFunc) {
    var content = params.content ? params.content : '';
    var title = params.title ? params.title : '';
    var okText = params.okText ? params.okText : '确定';
    var cancelText = params.cancelText ? params.cancelText : '取消';
    context.$Modal.info({
      title: content,
      content: '',
      closable: true,
      okText: okText,
      cancelText: cancelText,
      onOk: () => {
        if (handlerFunc) {
          handlerFunc();
        }
      },
      onCancel: () => {
        if (backFunc) {
          backFunc();
        }
      }
    });
  },
  /**
   * 成功
   * Modal.success(_this,{content: '提示语'}, function () {}, function () {});
   * */
  success: function (context, params, handlerFunc, backFunc) {
    var content = params.content ? params.content : '';
    var title = params.title ? params.title : '';
    var okText = params.okText ? params.okText : '确定';
    var cancelText = params.cancelText ? params.cancelText : '取消';
    context.$Modal.success({
      title: content,
      content: '',
      closable: true,
      okText: okText,
      cancelText: cancelText,
      onOk: () => {
        if (handlerFunc) {
          handlerFunc();
        }
      },
      onCancel: () => {
        if (backFunc) {
          backFunc();
        }
      }
    });
  },
  /**
   * 警告
   * Modal.warning(_this,{content: '提示语'}, function () {}, function () {});
   * */
  warning: function (context, params, handlerFunc, backFunc) {
    var content = params.content ? params.content : '';
    var title = params.title ? params.title : '';
    var okText = params.okText ? params.okText : '确定';
    var cancelText = params.cancelText ? params.cancelText : '取消';
    context.$Modal.warning({
      title: content,
      content: '',
      closable: true,
      okText: okText,
      cancelText: cancelText,
      onOk: () => {
        if (handlerFunc) {
          handlerFunc();
        }
      },
      onCancel: () => {
        if (backFunc) {
          backFunc();
        }
      }
    });
  },
  /**
   * 错误
   * Modal.error(_this,{content: '提示语'}, function () {}, function () {});
   * */
  error: function (context, params, handlerFunc, backFunc) {
    var content = params.content ? params.content : '';
    var title = params.title ? params.title : '';
    var okText = params.okText ? params.okText : '确定';
    var cancelText = params.cancelText ? params.cancelText : '取消';
    context.$Modal.error({
      title: content,
      content: '',
      closable: true,
      okText: okText,
      cancelText: cancelText,
      onOk: () => {
        if (handlerFunc) {
          handlerFunc();
        }
      },
      onCancel: () => {
        if (backFunc) {
          backFunc();
        }
      }
    });
  },
};
export default modal;
